
<%@page import="com.egame.manage.biz.server.gc.GameFileServiceImpl"%>
<%@page import="cn.egame.common.util.Utils"%>
<%@page import="cn.egame.interfaces.EnumType.GameStatus"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="cn.egame.common.model.PageData"%>
<%@page import="java.util.*"%>
<%@page import="cn.egame.interfaces.gc.GameInfo"%> 
<%@page import="cn.egame.interfaces.pu.AppParameter"%>   
<%@page import="com.egame.manage.biz.server.ManageClient"%>   
<%@page import="com.egame.manage.biz.server.gc.GameServiceImpl"%>  

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.9.1.js"></script>
<link type="text/css" rel="stylesheet" href="<%=request.getContextPath()%>/css/main.css"  />
<script type="text/javascript">
	$(document).ready(function() {
		if($("#gamestatusId").val()!=-1) {
			var manu = $("#gamestatusId").val();
			$("#gamestatus").val(manu);
		}
		
		if(($("#networktypeId").val()!=0)&&($("#networktypeId").val()!=-1)) {
			var scrp = $("#networktypeId").val();
			$("#networktype").val(scrp);
		}
	});
</script>
<title>产品管理</title>
</head>
<body>
<form action="" id="myform">	
<div class="matter_box">
	<h3 class="nopoint"><strong>产品管理</strong></h3>
	<div class="task_search">		
		<form name="search" action="<%=request.getContextPath() + "/caidan/game/list/manage.do" %>" method="post">		
		<%
			String shortName = "";
			if(request.getAttribute("shortName")!= null) {
				shortName = (String)request.getAttribute("shortName");
			}
			
			String gameName = "";
			if(request.getAttribute("gameName")!= null) {
				gameName = (String)request.getAttribute("gameName");
			}
			
			int gamestatus = -1;
			if((request.getAttribute("gamestatus") != null)&&(Integer.parseInt(request.getAttribute("gamestatus").toString())!=-1)) {
				gamestatus =  Integer.parseInt(request.getAttribute("gamestatus").toString());
			}
			
			int netType = 0;
			if((request.getAttribute("netType") != null)&&(Integer.parseInt(request.getAttribute("netType").toString())!=0)) {
				netType =  Integer.parseInt(request.getAttribute("netType").toString());
			}
		%>
		厂商简称：<input type=text name=shortName value="<%=shortName%>">
		产品名称：<input type=text name=gameName value="<%=gameName%>">
		产品状态：
		<select id="gamestatus" name="gamestatus">
		<option value=-1 selected>请选择</option>
		<%
			if(request.getAttribute("statusList")!=null){
			List<AppParameter> list = (List<AppParameter>)request.getAttribute("statusList");
			int status = 0;
			if(request.getAttribute("selectedStatus")!=null){
				status = (Integer) request.getAttribute("selectedStatus");
			}
				for(AppParameter bean:list){
					%>
						<option value=<%=bean.getRemark() %> <% if(Utils.toInt(bean.getRemark(), -1) == status){ %> selected="selected" <% } %>><%=bean.getName() %></option>
					<%
				}
			}
			%>
		</select>
		产品类型：
		<select id="networktype" name="networktype" >
		<option value=0 selected>请选择</option>
		<%
			if(request.getAttribute("networktype")!=null){
				int status = 0;
				if(request.getAttribute("selectedNetwork")!=null){
					status = (Integer) request.getAttribute("selectedNetwork");
				}
				List<AppParameter> list = (List<AppParameter>)request.getAttribute("networktype");
				for(AppParameter bean:list){
					%>
						<option value=<%=bean.getRemark() %><% if(Utils.toInt(bean.getRemark(), -1) == status){ %> selected="selected" <% } %>><%=bean.getName() %></option>
					<%
				}
			}
		%>
		</select>
		<input id="gamestatusId" type="hidden" value="<%=gamestatus %>"/>
		<input id="networktypeId" type="hidden" value="<%=netType %>"/>
		<input type="submit" value="查询" class="btn2">
		<a href="<%=request.getContextPath() + "/caidan/game/new/show.do" %>" class="btn2">创建产品</a>
		<!-- <a href="#">获取TCL应用编号</a> --> 
		</form>
	</div>
	<div class="mt10 clearfix pt10">
		<form name="data" action="">
		<table cellpadding="0" cellspacing="0" class="table2">
			<tr>
				<th>序号</th>
				<th>产品编号</th>
				<th>产品名称</th>
				<th>产品状态</th>
				<th>实体个数</th>
				<th>消费代码数量</th>
				<th>提交时间</th>
				<th>操作</th>
			</tr>
			<%
				Map<Integer,Integer> chargeMap = new HashMap<Integer,Integer>();
				if(request.getAttribute("chargeMap")!=null){
					chargeMap = (Map<Integer,Integer>)request.getAttribute("chargeMap");
				}
				if(request.getAttribute("pd")!=null){
					PageData pd = (PageData)request.getAttribute("pd");
					if(pd != null && pd.getContent() != null){
						List<GameInfo> list = (List<GameInfo>)pd.getContent();
						int i=1;
						for(GameInfo bean:list){
							%>
								<tr>
									<td><%=i++ %></td>
									<td><a href="<%=request.getContextPath() + "/caidan/game/show.do?gid=" + bean.getGId() %>"><%=bean.getGId() %></a></td>
									<td><%=bean.getGameName() %></td>
									<td><%=bean.getGameStatus()==null?"": (bean.getGameStatus()).getMessage() %></td>
									<td><a href="<%=request.getContextPath() + "/caidan/game/file/list.do?gid=" + bean.getGId() %>"><%=GameFileServiceImpl.getInstance().getFileCountByGId(bean.getGId()) %></a></td>
									<td><%=chargeMap.get(bean.getGId()) %></td>
									<td>
									<% 
										String time = "";
										if(bean.getInsertTime() != null && bean.getInsertTime().getTime()>0){
											time = Utils.toDateString(bean.getInsertTime(),"yyyy-MM-dd hh:mm:ss");
										}
									%>
										<%=time %>
									</td>								
									<td>
									<%
										int status = 0;
										if(request.getAttribute("selectedStatus")!=null){
											status = (Integer) request.getAttribute("selectedStatus");
										}
										String updateStatusUrl = request.getContextPath() + "/caidan/game/update/status.do?gid=" + bean.getGId()  + "&gamestatus=" + status + "&updatestatus=";
										if(bean.getGameStatus() == GameStatus.toAudit){
									%>
										<a href="<%=updateStatusUrl + GameStatus.auditPassed.value() %>">审核通过</a>
										<a href="<%=updateStatusUrl + GameStatus.auditNotPassed.value() %>">审核未通过</a>
									<%
										}else if(bean.getGameStatus() == GameStatus.auditNotPassed){
									%>
										<a href="<%=updateStatusUrl + GameStatus.auditPassed.value() %>">审核通过</a>
									<%
										}else if(bean.getGameStatus() == GameStatus.auditPassed){
									%>
										<a href="<%=request.getContextPath() + "/caidan/game/file/upload/show.do?gid=" + bean.getGId() %>">实体上传</a>
									<%
										}else if(bean.getGameStatus() == GameStatus.testPassed){
									%>
										<a href="<%=updateStatusUrl + GameStatus.published.value() %>">发布</a>
										<a href="<%=request.getContextPath() + "/caidan/game/file/upload/show.do?gid=" + bean.getGId() %>">实体上传</a>
									<%
										}else if(bean.getGameStatus() == GameStatus.business){
									%>
										<a href="<%=request.getContextPath() + "/caidan/game/file/upload/show.do?gid=" + bean.getGId() %>">实体上传</a>
									<%
										}else if(bean.getGameStatus() == GameStatus.published){
									%>
										<a href="<%=updateStatusUrl + GameStatus.business.value() %>">商用</a>
									<%
										}
									%>
										<a href="<%=request.getContextPath() + "/caidan/game/TCL/appid.do?gid=" + bean.getGId() %>">获取TCLAPPID</a>								
										
									</td>								
								</tr>
							<%
						}
					}
				}
			%>
		</table>		
	</form>
	</div>
	<%@ include file="../../page.in"  %> 
</div>
</form>
</body>
</html>